<extend name="Public/base" />

<block name="body">

    <style type="text/css">
    .title { font-size: 14px; font-weight: bold; }
    .content { margin: 5px 0; }
    </style>
     
    <div class="main-title">
        <h2>帖子详情 [ {$threads.title} ] <button class="btn btn-default btn-return" onclick="javascript:window.location.reload();return false;"><i class="glyphicon glyphicon glyphicon-refresh"></i> 刷新</button>
        <a href="{:U('Threads/index?circle_id='.$threads['circle_id'])}" class="btn btn-default btn-return"><i class="glyphicon glyphicon-share-alt"></i>返回</a>
        </h2>

    </div>
   
    <div class="cf">
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
             
        </div>
    </div>

    <div class="data-table table-striped">
    <table class="table table-bordered">
    <thead>
        <tr>
        <th width="" class="">主楼</th>
        <th width="150">时间</th>
        <th width="200">用户</th>
        <th width="200" class="">操作</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <div class="title">[ {$threads.title} ] <switch name="threads.attachment_type"><case value="1"><span class="label label-info">图片</span></case><case value="2"><span class="label label-info">视频</span></case></switch></div>
                <div class="content">{$threads.content}</div>
                <switch name="threads.attachment_type">
                <case value="1" > 
                    <div class="row">
                    <notempty name="threads.pics">
                        <volist name="threads.pics" id="p">
                        <div class="col-xs-2 col-md-4">
                              <img class="img-thumbnail" src="{$p.url|url_format}" alt="">
                        </div>
                        </volist>
                    </notempty>
                    </div>
                </case >
                <case value="2" > 
                <div class="video col-sm-10 col-md-10">
                    <div class="thumbnail">
                        <a target="_blank" href="{:U('video/edit?id='.$threads['video']['id'])}">
                            <img title="{$threads.video.title}" src="{$threads.video.thumb}"/>
                                </a>
                          <div class="caption">
                            <h3>{$threads.video.title}</h3>
                            <p>{$threads.video.detail}</p>
                          </div>
                        </div>
                        </div>
                </div>        
                </case >
                </switch>
            </td>
            <td>
            {$threads.created_at|time_format}
            </td>
             <td>
                <a target="_blank" href="{:U('frontUsers/profile?id='.$threads['uid'])}" >{$threads.uid} | {$threads.uid|get_nickname}</a>
            </td>
            <td></td>
        </tr>
    </tbody>
    </table>
    </div>


    <!-- 数据列表 -->
    <div class="data-table table-striped">
    <table class="table table-bordered">
    <thead>
        <tr>
        <th width="30">Floor</th>
        <!-- <th class="">ID</th> -->
        <th>内容</th>
        <th width="150">时间</th>
        <th width="200">用户</th>
        <th width="200" class="">操作</th>
        </tr>
    </thead>
    <tbody>
        <notempty name="_list">
        <volist name="_list" id="vo">
        <tr>
            <td <notempty name="vo.deleted_at">style="background: #8a8a8a; color:#FFF"</notempty> >
                {$vo.floor}
            </td>
            <td>
                 <div class="title"><switch name="vo.attachment_type"><case value="1"><span class="label label-info">图片</span></case><case value="2"><span class="label label-info">视频</span></case></switch></div>
                <div class="content">{$vo.content}</div>
                <switch name="vo.attachment_type">
                <case value="1" > 

                    <div class="upload-img-box">
                        <div class="row">
                    <notempty name="vo.pics">
                        <volist name="vo.pics" id="p">
                        <div class="col-xs-2 col-md-4">
                              <img class="img-thumbnail" src="{$p.url|url_format}" alt="">
                        </div>
                        </volist>
                    </notempty>
                    </div>
                    </div>
                </case >
                <case value="2" > 
                <div class="video col-sm-10 col-md-10">
                    <div class="thumbnail">
                        <a target="_blank" href="{:U('video/edit?id='.$vo['video']['id'])}">
                            <img title="{$vo.video.title}" src="{$vo.video.thumb}"/>
                                </a>
                          <div class="caption">
                            <h3>{$vo.video.title}</h3>
                            <p>{$vo.video.detail}</p>
                          </div>
                        </div>
                        </div>
                </div>        
                </case >
                </switch>
                <div id="reply-show-{$vo._id}"></div>
            </td>
            <td>{$vo.created_at|time_format}</td>
            <td>
                <a target="_blank" href="{:U('frontUsers/profile?id='.$vo['uid'])}" >{$vo.uid} | {$vo.uid|get_nickname}</a>
            </td>
            <td>
                <!-- <a class="btn btn-default btn-xs" title="编辑" href="{:U('edit?id='.$key)}"><i class="glyphicon glyphicon-pencil"></i></a> -->
                <notempty name="vo.deleted_at">
                <a class="label label-default">已删除</a>
                <a title="恢复" href="{:U('restore?id='.$vo['_id'])}" class="confirm ajax-get btn btn-success btn-xs"><i class="glyphicon glyphicon-share-alt"></i> 恢复</a>
                <else />
                <a title="删除" href="{:U('trash?id='.$vo['_id'])}" class="confirm ajax-get btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
                </notempty>
                <button data-id="{$vo._id}" class="btn btn-primary btn-xs replyloader" type="button">
                  <i class="glyphicon glyphicon-comment"></i> <span class="badge">{$vo.reply_count|default=0}</span>
                </button>
            </td>
        </tr>
        </volist>
        <else/>
        <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
        </notempty>
    </tbody>
    </table>
    </div>
    <div class="page">
        {$_page}
    </div>
    <div id="video-pre">
        <video controls="controls" autoplay="autoplay"></video>
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
    //搜索功能
    $("#search").click(function(){
        var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');

        var game  = $('.search-form').find('select').serialize();
        game = game.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        game = game.replace(/^&/g,'');

        if( url.indexOf('?')>0 ){
            url += '&' + query + '&' + game;
        }else{
            url += '?' + query + '&' + game;
        }
        window.location.href = url;
    });
    //回车搜索
    $(".search-input").keyup(function(e){
        if(e.keyCode === 13){
            $("#search").click();
            return false;
        }
    });
    //导航高亮
    highlight_subnav('{:U('index')}');

    $('.replyloader').click(function () {
        var _id = $(this).data('id');
        var show_id = '#reply-show-'+_id;

        if (!$(this).hasClass('reply-loaded'))
        {
            $.get("{:U('ajax_reply')}", {posts_id: _id}, function(res){
                if (res){
                    $(show_id).html(res);
                }
            });
            $(this).addClass('reply-loaded').addClass('reply-open');
            return;
        }else if ($(this).hasClass('reply-open')){
            $(show_id).hide();
            $(this).removeClass('reply-open');
        }else{
            $(show_id).show();
            $(this).addClass('reply-open');
        }
    });

     
    </script>
</block>
